<template>
  <div id="flowCountBox">
    <topSearch @toSearch="toSearch"></topSearch>
    <div class="table-conBtn">
      <freshCom @searchList="searchList"></freshCom>
    </div>
    <div>
      <el-row>
        <liveTimeEcharts ref="flowCountBar"></liveTimeEcharts>
      </el-row>
      <el-row>
        <viewsNumber ref="flowCountLine"></viewsNumber>
      </el-row>
    </div>
  </div>
</template>

<script>
import topSearch from '@component/shareBackFlow/echartsData/topSearch' // 上部搜索条件
import liveTimeEcharts from '@component/anchor/roomTotalDataBoard/bottomEchart/liveTimeEcharts' //直播时长
import viewsNumber from '@component/anchor/roomTotalDataBoard/bottomEchart/viewsNumber' //查看人数
import {getMonthFirstDay,getMonthLastDay} from "@/utils/yesterday.js"
import * as moment from 'moment'
export default {
  name: 'flowCountBox',
  msg: '',
  components: {
    topSearch,
    viewsNumber,
    liveTimeEcharts
  },
  data() {
    return {
      date: '',
      type: ''
    }
  },
  methods: {
    toSearch(date, type) {
      if(type === '0'){
        date = date+`/${date}`
      }
      if(type === '2'){
        let startDate = moment(date).startOf("month").format("YYYY-MM-DD")
        let endDate = moment(date).endOf('month').format("YYYY-MM-DD")
        date = `${startDate}/${endDate}`
      }
      this.date = date
      this.type = type
      this.$refs.flowCountLine.searchList(date, type)
      this.$refs.flowCountBar.searchList(date, type)
    },
    searchList() {
      this.toSearch(this.date, this.type)
    }
  }
}
</script>

<style lang="less">
#flowCountBox {
  .table-conBtn {
    margin-bottom: 0 !important;
  }
}
</style>
